home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / Grant's CGI Framework 1.0b14 / MyHandlers.c < prev    next >
Text File  |  1996-04-12  |  4KB  |  210 lines

  1. /*****
  2.  *
  3.  *    MyHandlers.c
  4.  *
  5.  *    Optional custom functions to handle special events. Includes:
  6.  *        document opening, startup and quitting
  7.  *
  8.  *    Modify these functions if you need to add to the standard support
  9.  *    built into the framework.
  10.  *
  11.  *    The function prototypes are contained in the relevent headers.
  12.  *    For example, AEHandlers.h contains the prototype for CustomOpenDocument
  13.  *
  14.  *    This is a support file for "Grant's CGI Framework".
  15.  *    Please see the license agreement that accompanies the distribution package
  16.  *    for licensing details.
  17.  *
  18.  *    Copyright ©1995,1996 by Grant Neufeld
  19.  *    grant@acm.com
  20.  *    http://arpp.carleton.ca/grant/
  21.  *
  22.  *****/
  23.  
  24. #include "MyConfiguration.h"
  25.  
  26. #include "compiler_stuff.h"
  27.  
  28. #if kCompileWithDragNDrop
  29. #include <Drag.h>
  30. #endif
  31.  
  32. #include "AEHandlers.h"
  33. #include "CGI.h"
  34. #include "DebugUtil.h"
  35. #include "EventUtil.h"
  36. #include "ListSTAR.h"
  37. #include "ProcessUtil.h"
  38. #include "Quit.h"
  39. #include "Startup.h"
  40. #include "WindowInt.h"
  41.  
  42.  
  43. /***  FUNCTIONS  ***/
  44.  
  45. #pragma segment AppleEvents
  46. /* The application is expected to open the given document, if possible */
  47. OSErr
  48. CustomOpenDocument ( FSSpec *theFile )
  49. {
  50.     OSErr    theErr;
  51.     
  52.     my_assert ( theFile != NULL, "\pCustomOpenDocument: theFile ptr is NULL" );
  53.     
  54.     theErr = noErr;
  55.     
  56.     return theErr;
  57. } /* CustomOpenDocument */
  58.  
  59.  
  60. #pragma segment Utilities
  61. /* Close any custom application windows */
  62. #if kCompileWithApplicationWindows
  63. OSErr
  64. CustomCloseWindow ( WindowPtr theWindow )
  65. {
  66.     OSErr    theErr;
  67.     
  68.     theErr = noErr;
  69.     
  70.     return theErr;
  71. } /* CustomCloseWindow */
  72. #endif
  73.  
  74.  
  75. /* If activate is true, restore theWindow's selections.
  76.     If activate is false, hide, or reduce to outline, theWindow's selections.
  77.     If theWindow has a grow box in the bottom right corner,
  78.     you should invalidate the growrect */
  79. #if kCompileWithApplicationWindows
  80. void
  81. CustomActivateWindow ( WindowPtr theWindow, Boolean activate )
  82. {
  83.     
  84. } /* CustomActivateWindow */
  85. #endif
  86.  
  87.  
  88. /* Draw contents of window on an update event */
  89. #if kCompileWithApplicationWindows
  90. void
  91. CustomUpdateWindow ( WindowPtr theWindow )
  92. {
  93.     
  94. } /* CustomUpdateWindow */
  95. #endif
  96.  
  97.  
  98. /* Support a click in a window.
  99.     If the click is on a dragable item, set onDragItem to true. */
  100. #if kCompileWithApplicationWindows
  101. void
  102. CustomClickInWindow ( WindowPtr theWindow, Point thePoint, Boolean *onDragItem )
  103. {
  104.     
  105. } /* CustomClickInWindow */
  106. #endif
  107.  
  108.  
  109. /* If you add windows that allow for text entry or you accept non-command-key
  110.     keyboard input, you need to support this function. */
  111. #if kCompileWithKeyboardEvents
  112. void
  113. CustomKeyPress ( EventRecord *theEvent )
  114. {
  115.     
  116. } /* CustomKeyPress */
  117. #endif
  118.  
  119.  
  120. /*  */
  121. #if kCompileWithDragNDrop
  122. OSErr
  123. CustomDoStartDrag ( EventRecord *theEvent, WindowPtr theWindow )
  124. {
  125.     OSErr            theErr;
  126.     GrafPtr            savePort;
  127.     DragReference    theDrag;
  128.     RgnHandle        dragRegion;
  129.     
  130.     GetPort ( &savePort );
  131.     SetPort ( (GrafPtr)theWindow );
  132.     
  133.     theErr = NewDrag ( &theDrag );
  134.     
  135.     if ( theErr == noErr )
  136.     {
  137.         dragRegion = NewRgn ();
  138.         
  139.         /* ••• You need to call a function that sets up the drag values such as:
  140.             theErr = customSetupDrag ( theWindow, theDrag, dragRegion, theEvent->where ); */
  141.     }
  142.     else
  143.     {
  144.         theDrag = nil;
  145.     }
  146.     
  147.     SetPort ( savePort );
  148.     
  149.     theErr = TrackDrag ( theDrag, theEvent, dragRegion );
  150.     
  151.     if ( dragRegion != CustomOpenDocument )
  152.     {
  153.         DisposeRgn ( dragRegion );
  154.     }
  155.     
  156.     if ( theDrag != nil )
  157.     {
  158.         DisposeDrag ( theDrag );
  159.     }
  160.         
  161.     return theErr;
  162. } /* CustomDoStartDrag */
  163. #endif
  164.  
  165. /**  **/
  166. #pragma mark -
  167.  
  168. /* The prototype for this function is in "ProcessUtil.h" */
  169. #if kCompileWithDeferredTask
  170. void
  171. CustomDeferredTask ( void )
  172. {
  173.     
  174. } /* CustomDeferredTask */
  175. #endif
  176.  
  177.  
  178. /**  **/
  179. #pragma mark -
  180.  
  181. #pragma segment Startup
  182. /* add things like installing additional AppleEvent handlers in this function */
  183. OSErr
  184. CustomStartup ( void )
  185. {
  186.     OSErr    theErr;
  187.     Boolean    success;
  188.     
  189.     CustomCGIStartup (); /* CGI Specific */
  190.     success = CustomListSTARStartup ();    /* ListSTAR Specific */
  191.     
  192.     theErr = noErr;
  193.     
  194.     return theErr;
  195. } /* CustomStartup */
  196.  
  197.  
  198. #pragma segment Main
  199. /* Unless allowUserInteract is true, don't make any calls that might require
  200.     user interaction.
  201.     Return true if your clean up was successful and quitting should proceed. */
  202. Boolean
  203. CustomQuit ( Boolean allowUserInteract )
  204. {
  205.     return CustomCGIQuit ( allowUserInteract );
  206. } /* CustomQuit */
  207.  
  208.  
  209. /*****  EOF  *****/
  210.